﻿using System;
using System.Threading;
using Mono.Collections.Generic;

namespace Mono.Cecil
{
	// Token: 0x02000072 RID: 114
	public sealed class GenericParameterConstraint : ICustomAttributeProvider, IMetadataTokenProvider
	{
		// Token: 0x170000E9 RID: 233
		// (get) Token: 0x060004B0 RID: 1200 RVA: 0x0001C960 File Offset: 0x0001AB60
		// (set) Token: 0x060004B1 RID: 1201 RVA: 0x00003D25 File Offset: 0x00001F25
		public TypeReference ConstraintType
		{
			get
			{
				return this.constraint_type;
			}
			set
			{
				this.constraint_type = value;
			}
		}

		// Token: 0x170000EA RID: 234
		// (get) Token: 0x060004B2 RID: 1202 RVA: 0x0001C978 File Offset: 0x0001AB78
		public bool HasCustomAttributes
		{
			get
			{
				bool flag = this.custom_attributes != null;
				bool result;
				if (flag)
				{
					result = (this.custom_attributes.Count > 0);
				}
				else
				{
					bool flag2 = this.generic_parameter == null;
					result = (!flag2 && this.GetHasCustomAttributes(this.generic_parameter.Module));
				}
				return result;
			}
		}

		// Token: 0x170000EB RID: 235
		// (get) Token: 0x060004B3 RID: 1203 RVA: 0x0001C9CC File Offset: 0x0001ABCC
		public Collection<CustomAttribute> CustomAttributes
		{
			get
			{
				bool flag = this.generic_parameter == null;
				Collection<CustomAttribute> result;
				if (flag)
				{
					bool flag2 = this.custom_attributes == null;
					if (flag2)
					{
						Interlocked.CompareExchange<Collection<CustomAttribute>>(ref this.custom_attributes, new Collection<CustomAttribute>(), null);
					}
					result = this.custom_attributes;
				}
				else
				{
					result = (this.custom_attributes ?? this.GetCustomAttributes(ref this.custom_attributes, this.generic_parameter.Module));
				}
				return result;
			}
		}

		// Token: 0x170000EC RID: 236
		// (get) Token: 0x060004B4 RID: 1204 RVA: 0x0001CA38 File Offset: 0x0001AC38
		// (set) Token: 0x060004B5 RID: 1205 RVA: 0x00003D2F File Offset: 0x00001F2F
		public MetadataToken MetadataToken
		{
			get
			{
				return this.token;
			}
			set
			{
				this.token = value;
			}
		}

		// Token: 0x060004B6 RID: 1206 RVA: 0x00003D39 File Offset: 0x00001F39
		internal GenericParameterConstraint(TypeReference constraintType, MetadataToken token)
		{
			this.constraint_type = constraintType;
			this.token = token;
		}

		// Token: 0x060004B7 RID: 1207 RVA: 0x00003D51 File Offset: 0x00001F51
		public GenericParameterConstraint(TypeReference constraintType)
		{
			Mixin.CheckType(constraintType, Mixin.Argument.constraintType);
			this.constraint_type = constraintType;
			this.token = new MetadataToken(TokenType.GenericParamConstraint);
		}

		// Token: 0x0400012D RID: 301
		internal GenericParameter generic_parameter;

		// Token: 0x0400012E RID: 302
		internal MetadataToken token;

		// Token: 0x0400012F RID: 303
		private TypeReference constraint_type;

		// Token: 0x04000130 RID: 304
		private Collection<CustomAttribute> custom_attributes;
	}
}
